package com.team7.home.controller;

import com.team7.common.vo.BottomArticleVo;
import com.team7.common.vo.CommonResult;
import com.team7.home.service.BottomArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: team7-object-master
 * @description:
 * @author: 王金涛
 * @create: 2021-10-20 15:49
 **/

@RestController
@RequestMapping("home/bottomarticle")
public class BottomArticleController {
    @GetMapping("aa")
    public void aa(){
        System.out.println("111111111111111111111");
    }

    @Autowired
    private BottomArticleService bottomArticleService;

    /**
     * 分页查询所有数据
     * @param page
     * @param limit
     * @param bottomArticleVo
     * @return
     */
    @PostMapping("getAllBottomArticle/{page}/{limit}")
    public CommonResult getAllBottomAricle(@PathVariable("page") Integer page,
                                           @PathVariable("limit") Integer limit,
                                           @RequestBody BottomArticleVo bottomArticleVo){
        return bottomArticleService.getAllBottomArticle(page, limit, bottomArticleVo);
    }

    @PostMapping("addBottomArticle")
    public CommonResult addBottomArticle(@RequestBody BottomArticleVo bottomArticleVo){
        return bottomArticleService.addBottomArticle(bottomArticleVo);
    }

    @PostMapping("editBottomArticle")
    public CommonResult editBottomArticle(@RequestBody BottomArticleVo bottomArticleVo){
        return bottomArticleService.editBottomArticle(bottomArticleVo);
    }

    @PostMapping("deletedBottomArticle")
    public CommonResult deletedBottomArticle(@RequestBody BottomArticleVo bottomArticleVo){
        return bottomArticleService.deleteBottomArticle(bottomArticleVo.getId());
    }

    @PostMapping("changeStatus/{id}/{isDisable}")
    public CommonResult changeStatus (@PathVariable("id") String id,
                                      @PathVariable("isDisable") Integer isDisable){
        return bottomArticleService.changeStatus(id,isDisable);
    }

}
